<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/3/003
 * Time: 15:41
 */

namespace app\api\controller;

use think\Controller;
use think\Cookie;
use app\api\model\StoreComment as CommentModel;

class Storecomment extends Base
{
    //添加评论
    public function insertComment()
    {
        $arr = [
            'user_id' => input('user_id'),
            'store_id' => input('store_id'),
            'score' => input('score'),
            'comment' => input('comment'),
            'consume_id' => input('consume_id')
        ];
        $model = new CommentModel();
        $data = $model->insertComment($arr);
        return self::apiResp($data);
    }

    //用户查看评论
    public function getComment()
    {
        //评论id
        $consume_id = input('consume_id');
        $data = CommentModel::getComment($consume_id);
        return self::apiResp($data);
    }


    //获取店铺的评论
    public function getStoreComment()
    {
        //店铺id
        $store_id = input('store_id');
        $user_id = input('user_id');
        $data = CommentModel::getStoreComment($store_id,$user_id);
        return self::apiResp($data);
    }

    //点赞
    public function likeComment()
    {
        $user_id = input('user_id');
        $comment_id = input('comment_id');
        $data = CommentModel::likeComment($user_id,$comment_id);
        return self::apiResp($data);
    }

}